package org.ccpp.portal.emails;

import java.awt.Toolkit;
import java.io.FileInputStream;
import java.net.URL;

public class EmailCarga {

	public static String carga(String nombre) throws Exception{
		String sTexto="";
		boolean error=false;
		FileInputStream fis=null;
		try{
			String email=EmailCarga.class.getResource(nombre).getFile();
			fis=new FileInputStream(email); 
			byte b[]=new byte[1024];
			while (fis.available()>0){
				int n=fis.read(b);
				sTexto+=new String(b, 0, n);
			}
		}catch(Exception e){
			error=true;
		}finally{
			try{ fis.close(); }catch(Exception e2){}
		}
		if (error){
			throw new Exception("No se pudo cargar fichero");
		}
		return sTexto;
	}
}
